﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HtmlAgilityPack;

namespace ZCrawler
{
    public class ZCrawlDataGetImgUrlProcessor : ZCrawlDataProcessor
    {
        public override string Process(string str)
        {
            string result = str;
            HtmlDocument HD = new HtmlDocument();
            HD.LoadHtml(str);
            var NoAltElements = HD.DocumentNode.SelectNodes("//img[not(@alt)]");
            if (NoAltElements != null)
            {
                HtmlNode node = NoAltElements.First();
                if(node != null)
                {
                    result = node.OuterHtml;
                }
            }
            return result;
        }

        public override string Description
        {
            get
            {
                return "Image url parser";
            }
        }
    }
}
